home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / GotoDialog.C < prev    next >
C/C++ Source or Header  |  1992-04-27  |  2KB  |  88 lines

  1. #ifdef __GNUG__
  2. #pragma implementation
  3. #endif
  4.  
  5. #include "GotoDialog.h"
  6.  
  7. #include "Class.h"
  8. #include "Dialog.h"
  9. #include "Window.h"
  10. #include "Fields.h"
  11. #include "TextView.h"
  12. #include "BorderItems.h"
  13. #include "Buttons.h"
  14. #include "Document.h"
  15. #include "WindowSystem.h"
  16. #include "ObjectTable.h"
  17. #include "Expander.h"
  18. #include "Math.h"
  19.  
  20. static GotoDialog *gotoDialog;
  21.  
  22. //---- entry Point -------------------------------------------------------------
  23.  
  24. void GotoLine(TextView *tv)
  25. {
  26.     if (gotoDialog == 0)
  27.     gotoDialog= new GotoDialog;
  28.     gotoDialog->ShowGotoDialog(tv);
  29. }
  30.  
  31. ONEXIT(GotoDialog)
  32. {
  33.     SafeDelete(gotoDialog);
  34. }
  35.  
  36. //---- GotoDialog --------------------------------------------------------------
  37.  
  38. NewMetaImpl(GotoDialog, Dialog, (TP(view), TP(line), TP(gotoDialog)));
  39.  
  40. GotoDialog::GotoDialog() : Dialog("Goto")
  41. {
  42.     line= 0;
  43. }
  44.  
  45. void GotoDialog::ShowGotoDialog(TextView *v)
  46. {
  47.     if (v) {
  48.     view= v;
  49.     if (ShowOnWindow(v->GetWindow()) == cIdYes) {
  50.         int at= line->GetValue();
  51.         LineMark *lm= view->MarkAtLine(at-1);
  52.         view->SetSelection(lm->Pos(), lm->End(), TRUE);
  53.         view->RevealSelection();
  54.         GraphicDelay(500);
  55.         view->SetSelection(lm->Pos(), lm->Pos(), TRUE);
  56.     }
  57.     }
  58. }
  59.  
  60. VObject *GotoDialog::DoMakeContent()
  61. {
  62.     return
  63.     new Matte(10, 
  64.         new VExpander(20,
  65.         new HBox(10, (VObjAlign)(eVObjVBase|eVObjHExpand),
  66.             new TextItem("Go to line:"),
  67.             line= new IntField(cIdNone),
  68.             0
  69.         ),
  70.         new HBox(20, (VObjAlign)(eVObjVBase|eVObjHEqual|eVObjHExpand),
  71.             new ActionButton(cIdYes,    "Go to", TRUE),
  72.             new ActionButton(cIdCancel, "Cancel"),
  73.             0
  74.         ),
  75.         0
  76.         )
  77.     );
  78. }
  79.  
  80. void GotoDialog::DoSetDefaults()
  81. {
  82.     int f, t;
  83.     view->GetSelection(&f, &t);
  84.     line->SetValue(view->CharToLine(f)+1);
  85.     line->SetRange(1, Math::Max(1, view->NumberOfLines()));
  86. }
  87.  
  88.